/**
 * 提现脚本
 */
define(function (require, exports, module) {


    var UI = require("js/UI");
    var $homeCnt = $("#home .cnt");

    var reg_num = /^[1-9]+(\d)*$/;

    var $withdrawForm = $homeCnt.find(".withdrawForm");


    //<editor-folder desc='选择提现方式'>
    var $select = $withdrawForm.find(".G_select"), $ul = $select.find("ul"),
        $bankIpt = $select.find("input[type=hidden]");
    var $tit = $select.find(".tit").click(function () {
        if($ul.is(":visible")){
            $ul.hide()
        }else{
            $ul.show();
        }
    })
    var $bank = $ul.find("li").unbind("click.selected").bind("click.selected", function () {
        var $this = $(this), $clone = $this.find("img,span").clone();
        var id = $this.attr("id");
        $tit.find("img,span").remove();
        $tit.prepend($clone);
        $bank.removeClass("selected");
        $this.addClass("selected");
        $ul.hide();
        $bankIpt.val(id);
    })
    $(document).unbind("click.stop").bind("click.stop", function () {
        $ul.hide();
    })
    $select.unbind("click.stop").bind("click.stop", function (e) {
        e.stopPropagation();
    })
    //</editor-folder>

    //<editor-folder desc='form 提交'>
    var $moneyIpt = $withdrawForm.find(".ipt1 input"), $password = $withdrawForm.find("input[type='password']");
    $withdrawForm.find("button[type=submit]").unbind("click.sub").bind("click.sub", function () {
        var _money = $.trim($moneyIpt.val())

        if (!_money) {
            UI.tooltip("error", "请输入提现金额");
            $moneyIpt.focus();
            return false
        } else {
            if (!_money.match(reg_num)) {
                UI.tooltip("error", "请输入正整数");
                $moneyIpt.focus();
                return false
            }
        }
        if(!$.trim($password.val())){
            UI.tooltip("error", "请输入支付密码");
            $password.focus();
            return false
        }
    })
    //</editor-folder>

})